<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2023/6/19
 * Time: 下午1:36
 */

namespace app\common\lib\util;

use app\common\lib\astrolog\Astrolog;

/**
 * 档案训练数据处理
 * Class RecordTrain
 * @package app\common\lib\util
 */
class RecordTrain
{
    // 行星点
    protected $planet_name = [
        0 => '太阳', 1 => '月亮', 2 => '水星', 3 => '金星', 4 => '火星',
        5 => '木星', 6 => '土星', 7 => '天王星', 8 => '海王星', 9 => '冥王星',
        10 => '凯龙星', 11 => '莉莉斯', 12 => '北交点', 13 => '婚神星', 14 => '福点',
        15 => '宿命点', 16 => '南交点',
        17 => '上升', 18 => '天底', 19 => '下降', 20 => '天顶',
    ];
    // 12星座
    protected $sign_name = [
        1 => '白羊', 2 => '金牛', 3 => '双子', 4 => '巨蟹',
        5 => '狮子', 6 => '处女', 7 => '天秤', 8 => '天蝎',
        9 => '射手', 10 => '摩羯', 11 => '水瓶', 12 => '双鱼'
    ];

    protected $phase_name = [
//            0 => '合相',
//            60 => '正相位',
//            90 => '负相位',
//            120 => '正相位',
//            180 => '负相位',
        0 => '合相',
        60 => '六分相',
        90 => '四分相',
        120 => '三分相',
        180 => '对分相',
    ];

    /**
     * 档案信息数据转换为训练专用的文本
     * @param array $record
     * @return string
     */
    public function format($record = []): string
    {
        $res = '';
        if (empty($record))
        {
            return $res;
        }
        // 获取用户本命盘数据
        $userSetting['natal'] = json_decode('{"planet":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]],"phase":{"0":[1,6],"60":[1,4],"90":[1,5],"120":[1,5],"180":[1,5],"45":[0,0],"135":[0,0],"30":[0,0],"150":[0,0],"72":[0,0],"144":[0,0]},"arabic":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"h_sys":"p","ecliptic":0,"firdaria":"default","profection_push_direction":0,"decanates":0,"bound_type":"default","ayanamsa":0}', true);
        $astro = Astrolog::getInstance()
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(true)
            ->setUserSetting($userSetting)
            ->setVersion(2);
        $natalData = $astro
            ->setRecode1($record)
            ->setGetDatas(['natal'])
            ->getAstroDatas()
            ->getDatas('natal');

        $res .= '行星落座落宫：';
        foreach ($natalData['planets'] as $planet)
        {
            if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 17, 18, 19, 20], false))
            {
                if ($planet['id'] === 17)
                {
                    $res .= ' 基本点：';
                }
//                $res .= $this->planet_name[$planet['id']] . $this->sign_name[$planet['in_sign_id']] . '座' . $planet['in_house_id'] . '宫 ';
                if ($planet['id'] < 17)
                {
                    $res .= $this->planet_name[$planet['id']] . $this->sign_name[$planet['in_sign_id']] . '座' . $planet['in_house_id'] . '宫 ';
                } else
                {
                    $res .= $this->planet_name[$planet['id']] . $this->sign_name[$planet['in_sign_id']] . '座 ';
                }
            }
        }
        $res .= ' 宫头星座：';
        foreach ($natalData['houses'] as $h => $house)
        {
            $res .= $h . '宫宫头星座' . $this->sign_name[$house['in_sign_id']] . '座 ';
        }
        $res .= '宫主星：';
        foreach ($natalData['houses'] as $h => $house)
        {
//            $res .= $h . '宫主宰星' . $this->planet_name[$house['protect_id']] . ' ';
            $res .= $h . '宫主宰星' . $this->planet_name[$house['protect_ancient_id']] . '落在第' . $house['protect_ancient_inhouse_id'] . '宫 ';
        }
        $res .= '行星相位：';
        $phaseArr = [];
        foreach ($natalData['phase'] as $phase)
        {
            if ($phase['id1'] < $phase['id2'] && $phase['id2'] < 10)
            {
                $phaseArr[] = 1;
                if (count($phaseArr) < 20)
                {
                    $res .= $this->planet_name[$phase['id1']] . '和' . $this->planet_name[$phase['id2']] . $this->phase_name[$phase['phase_deg']] . ' ';
                }
            }
        }
        $res .= '用户性别：' . (((int)$record['type']) === 1 ? '男生' : '女生');
        $res .= ' 用户年龄：' . (date('Y') - $record['year']) . '岁。';
        // 增加互容接纳信息 20240123
        // $details['characteristic'] = $this->receptOrMutualRecept($details['planets']);
        if (isset($natalData['characteristic']) && !empty($natalData['characteristic']))
        {
            $res .= ' 互容接纳：';
            foreach ($natalData['characteristic'] as $k1 => $v1)
            {
                if ($k1 <= 2)
                {
                    foreach ($v1 as $k2 => $v2)
                    {
                        switch ($k1)
                        {
                            case 1:
                                // 接纳
                                $res .= $this->planet_name[$v2['id1']] . '被' . $this->planet_name[$v2['id2']] . '接纳 ';
                                break;
                            case 2:
                                // 互容
                                $res .= $this->planet_name[$v2['id1']] . '与' . $this->planet_name[$v2['id2']] . '互容 ';
                                break;
                        }
                    }
                }
            }
        }
        return $res;
    }

    /**
     * 文本形式的星盘数据，支持多种类星盘解析
     * @param array $record 档案信息
     * @param string $datetime 推运日期 例：2023/7/17-2024/7/17
     * @param int $chart 星盘类型 0->本命，1->行运，2->三限，3->月返，4->日返，5->次限，6->法达，7->比较1
     * @return array
     */
    public function format2($record = [], $datetime = '', $chart = 0): array
    {
        // 如果不是本命，需要传入时间信息
        $timeinfo = [];
        $record_time = '';
        if ($datetime !== '' && strpos($datetime, '-'))
        {
            $dateArr = explode('-', $datetime);
            $startTime = strtotime($dateArr[0] . ' 00:00:00');
            $endTime = strtotime($dateArr[1] . ' 00:00:00');
            $timestamp = ($startTime + $endTime) / 2;
            $timeinfo = [
                'year' => date('Y', $timestamp),
                'month' => date('m', $timestamp),
                'day' => date('d', $timestamp),
                'hour' => date('H', $timestamp),
                'minute' => date('i', $timestamp),
                'timezone' => 8,
                'is_summer' => 0
            ];
            $record_time = date('Y/m/d H:i', $timestamp);
            // 开启检测星盘类型和时间是否对应，若不对应则根据时间段切换
//            $timeDiff = ($endTime - $startTime) / 86400; // 时段差为几天
//            if ($timeDiff > 366)
//            {
//                $chart = 5;
//            } elseif ($timeDiff > 31)
//            {
//                $chart = 4;
//            } elseif ($timeDiff > 7)
//            {
//                $chart = 3;
//            } elseif ($timeDiff > 1)
//            {
//                $chart = 2;
//            } else
//            {
//                $chart = 1;
//            }
        }

        $arabics = [
            ['name' => '精神点', 'abbreviation' => '精', 'status' => 1,],
            ['name' => '爱神点', 'abbreviation' => '爱', 'status' => 0,],
            ['name' => '胜利点', 'abbreviation' => '胜', 'status' => 0,],
            ['name' => '必需点', 'abbreviation' => '必', 'status' => 0,],
            ['name' => '勇气点', 'abbreviation' => '勇', 'status' => 0,],
            ['name' => '复仇点', 'abbreviation' => '仇', 'status' => 0,],
            ['name' => '旺点', 'abbreviation' => '旺', 'status' => 0,],
            ['name' => '基础点', 'abbreviation' => '基', 'status' => 0,],
            ['name' => '朔望点', 'abbreviation' => '朔', 'status' => 0,],
            ['name' => '父亲点', 'abbreviation' => '父', 'status' => 0,],
            ['name' => '母亲点', 'abbreviation' => '母', 'status' => 0,],
            ['name' => '兄弟数量点', 'abbreviation' => '兄1', 'status' => 0,],
            ['name' => '幸福婚姻点', 'abbreviation' => '婚3', 'status' => 0,],
            ['name' => '桃花点', 'abbreviation' => '桃', 'status' => 0,],
            ['name' => '得子时间点', 'abbreviation' => '子1', 'status' => 0,],
            ['name' => '儿子点', 'abbreviation' => '儿', 'status' => 0,],
            ['name' => '女儿点', 'abbreviation' => '女', 'status' => 0,],
            ['name' => '慢性疾病点', 'abbreviation' => '疾', 'status' => 0,],
            ['name' => '兄弟点', 'abbreviation' => '兄', 'status' => 0,],
            ['name' => '财产点', 'abbreviation' => '财', 'status' => 0,],
            ['name' => '男性婚姻点1', 'abbreviation' => '婚1', 'status' => 0,],
            ['name' => '女性婚姻点1', 'abbreviation' => '婚1', 'status' => 0,],
            ['name' => '男性婚姻点2', 'abbreviation' => '婚2', 'status' => 0,],
            ['name' => '女性婚姻点2', 'abbreviation' => '婚2', 'status' => 0,],
            ['name' => '子女点', 'abbreviation' => '子', 'status' => 0,],
            ['name' => '死亡点1', 'abbreviation' => '死1', 'status' => 0,],
            ['name' => '死亡点2', 'abbreviation' => '死2', 'status' => 0,],
        ];

        $push_fortune = [//推运基点
            0 => [
                'id' => 1,
                'name' => '福点',
                'status' => 1
            ],
            1 => [
                'id' => 2,
                'name' => '精神点',
                'status' => 0
            ],
            2 => [
                'id' => 0,
                'name' => '太阳',
                'status' => 0
            ],
            3 => [
                'id' => 1,
                'name' => '月亮',
                'status' => 0
            ],
            4 => [
                'id' => 1,
                'name' => '水',
                'status' => 0
            ],
            5 => [
                'id' => 1,
                'name' => '木',
                'status' => 0
            ],
            6 => [
                'name' => '金',
                'status' => 0
            ],
            7 => [
                'id' => 1,
                'name' => '火',
                'status' => 0
            ],
            8 => [
                'id' => 1,
                'name' => '土',
                'status' => 0
            ],
            9 => [
                'name' => '上升',
                'status' => 0
            ],
            10 => [
                'name' => '下降',
                'status' => 0
            ],
            11 => [
                'name' => '中天',
                'status' => 0
            ],
            12 => [
                'name' => '天底',
                'status' => 0
            ],
            13 => [
                'name' => '擢升点',
                'status' => 0
            ],
            14 => [
                'name' => '基本点',
                'status' => 0
            ],
            15 => [
                'name' => '爱神点',
                'status' => 0
            ],
            16 => [
                'name' => '胜利点',
                'status' => 0
            ],
            17 => [
                'name' => '必须点',
                'status' => 0
            ],
            18 => [
                'name' => '勇气点',
                'status' => 0
            ],
            19 => [
                'name' => '复仇点 / 报应点',
                'status' => 0
            ],
        ];
        // 星盘设置
        $userSetting = [
            // 本命盘设置（终生）
            'natal' => [
                'asp_orb_all' => [0 => 7, 60 => 6, 90 => 7, 120 => 7, 180 => 7],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            // 行运盘设置（某天）
            'transits' => [
                'asp_orb_all' => [0 => 0, 60 => 0, 90 => 0, 120 => 0, 180 => 0],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [1, 5, 1, 1, 1, 1, 1, 1, 1, 1],
                'h_sys' => 'p',
            ],
            // 三限盘设置（某周）
            'thirdprogressed' => [
                'asp_orb_all' => [0 => 0, 60 => 0, 90 => 0, 120 => 0, 180 => 0],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [1, 3, 1, 1, 1, 1, 1, 1, 1, 1],
                'h_sys' => 'p',
            ],
            // 月返盘设置（某月）
            'lunar_return' => [
                'asp_orb_all' => [0 => 7, 60 => 6, 90 => 7, 120 => 7, 180 => 7],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            // 日返盘设置（某年）
            'solar_return' => [
                'asp_orb_all' => [0 => 7, 60 => 6, 90 => 7, 120 => 7, 180 => 7],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            // 次限盘设置（十年）
            'progressions' => [
                'asp_orb_all' => [0 => 0, 60 => 0, 90 => 0, 120 => 0, 180 => 0],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111111111111111',
                'planet_orb_all' => [1, 3, 1, 1, 1, 1, 1, 1, 1, 1],
                'h_sys' => 'p',
                'firdaria' => 'default',
            ],

            'fortune' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'w',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'zodrel' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'w',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0,//十度主星[0=>'古典',1=>'印度']
                'push_fortune' => $push_fortune
            ],
            'dodekatemorion' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'w',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'trimsamsa' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'w',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'now' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'thirdprogressedvsnatal' => [
                'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'progressionsvsnatal' => [
                'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'solar' => [
                'asp_orb_all' => [0 => 1, 60 => 0, 90 => 1, 120 => 0, 180 => 1, 30 => 0, 150 => 1, 45 => 1, 135 => 1, 72 => 0, 144 => 0],
                'asps_display' => [0, 45, 90, 135, 180],
                'planets_display' => '111111111100100001111',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'solar_returnvsnatal' => [
                'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'lunar_returnvsnatal' => [
                'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'firdaria' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
                'firdaria' => 'default',//法达星序[0=>月亮在火星后，1=》月亮在水星后]
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'profection' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0,//十度主星[0=>'古典',1=>'印度']
                'profection_push_direction' => 0//小限推运方向[0=>'顺时针',1=>'逆时针']
            ],
            'synastry' => [
                'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'composite' => [
                //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'composite_thirdprogressed' => [
                //            'asp_orb_all'=> [0=>5,60=>4,90=>5,120=>5,180=>5,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'composite_progressions' => [
                //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'davison' => [
                //            'asp_orb_all'=> [0=>6,60=>5,90=>6,120=>6,180=>6,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'marks' => [
                //            'asp_orb_all'=> [0=>6,60=>5,90=>6,120=>6,180=>6,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'marks_thirdprogressed' => [
                //            'asp_orb_all'=> [0=>5,60=>4,90=>5,120=>5,180=>5,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'marks_progressions' => [
                //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'divination' => [
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
                'extent_type' => 0,//[0=>埃及界，1=》托勒密界]
                'arabics' => $arabics,
                'decanates' => 0//十度主星[0=>'古典',1=>'印度']
            ],
            'synastry_thirdprogressed' => [
                //            'asp_orb_all'=> [0=>3,60=>2,90=>3,120=>3,180=>3,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'synastry_progressions' => [
                'asp_orb_all' => [0 => 2, 60 => 1, 90 => 2, 120 => 2, 180 => 2, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'davison_thirdprogressed' => [
                //            'asp_orb_all'=> [0=>5,60=>4,90=>5,120=>5,180=>5,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
            'davison_progressions' => [
                //            'asp_orb_all'=> [0=>4,60=>3,90=>4,120=>4,180=>4,30=>1,150=>2,45=>2,135=>2,72=>2,144=>2],
                'asp_orb_all' => [0 => 8, 60 => 6, 90 => 7, 120 => 7, 180 => 7, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100000001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
        ];
        $chartList = [
            '本命盘',
            '行运盘',
            '三限盘',
            '月返盘',
            '日返盘',
            '次限盘',
            '法达盘',
            '合盘',
        ];
        $chartName = $chartList[$chart];
        $chartNameEasy = mb_substr($chartName, 0, 2);
        $res = $chartName . '\n';
        /**
         * 终生运势 本命
         * 某天运势 行运
         * 某周运势 三限
         * 某月运势 月返
         * 某年运势 日返
         * 十年运势 次限
         */
        switch ($chart)
        {
            case 0:
                // 本命
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(true)
                    ->setUserSetting($userSetting)
                    ->setVersion(2);
                $natalData = $astro
                    ->setRecode1($record)
                    ->setGetDatas(['natal'])
                    ->getAstroDatas()
                    ->getDatas('natal');

                $res .= $chartNameEasy . '行星落宫：';
                foreach ($natalData['planets'] as $planet)
                {
//                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 16], false))
//                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 16], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '行星落座：';
                foreach ($natalData['planets'] as $planet)
                {
                    // 行星/上升/天顶的落座
//                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 16], false))
//                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
//                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 16], false))
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 16, 17, 20], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在' . $this->sign_name[$planet['in_sign_id']] . '座 ';
                    }
                }
                $res .= $chartNameEasy . '宫主星：';
                foreach ($natalData['houses'] as $h => $house)
                {
                    $res .= $chartNameEasy . $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                $res .= $chartNameEasy . '行星相位：';
                foreach ($natalData['phase'] as $phase)
                {
                    // 行星与上升/天顶的相位
//                    if ($phase['id1'] < $phase['id2'] && $phase['id1'] < 10 && $phase['id2'] < 10)
                    if ($phase['id1'] < $phase['id2'] && $phase['id1'] < 10 && in_array($phase['id2'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$phase['id1']] . '和' . $this->planet_name[$phase['id2']] . $this->phase_name[$phase['phase_deg']] . ' ';
                    }
                }
                $res .= $chartNameEasy . '宫头星座：';
                foreach ($natalData['houses'] as $h => $house)
                {
                    $res .= $chartNameEasy . $h . '宫宫头星座' . $this->sign_name[$house['in_sign_id']] . '座 ';
                }
//                $res .= '用户性别：' . (((int)$record['type']) === 1 ? '男生' : '女生');
//                $res .= ' 用户年龄：' . (date('Y') - $record['year']) . '岁。';
                break;
            case 1:
                /**
                 * 某天运势 行运 transits natal
                 * 行运行星落宫：行运太阳落在第11宫 行运月亮落在第2宫 行运水星落在第6宫 行运金星落在第6宫 行运火星落在第2宫 行运木星落在第3宫 行运土星落在第11宫 行运天王星落在第5宫 行运海王星落在第1宫 行运冥王星落在第9宫 本命行星落宫：本命太阳落在第10宫 本命月亮落在第9宫 本命水星落在第10宫 本命金星落在第7宫 本命火星落在第11宫 本命木星落在第3宫 本命土星落在第9宫 本命天王星落在第2宫 本命海王星落在第4宫 本命冥王星落在第12宫 行星相位：行运太阳和本命太阳四分相 行运太阳和本命月亮对分相 行运月亮和本命金星对分相 行运月亮和本命火星合相 行运月亮和本命天王星六分相 行运水星和本命水星六分相 行运水星和本命海王星四分相 行运金星和本命火星六分相 行运金星和本命土星对分相 行运火星和本命火星合相 行运火星和本命木星对分相 行运木星和本命木星四分相 行运木星和本命天王星六分相 行运土星和本命土星三分相 行运土星和本命天王星六分相 行运天王星和本命天王星六分相 行运海王星和本命海王星合相 行运冥王星和本命冥王星对分相
                 */
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting($userSetting)
                    ->setVersion(2)
                    ->setRecode1($record)
                    ->setAdvance($timeinfo)
                    ->setGetDatas(['transits'])
                    ->getAstroDatas();
                $astroData = $astro->getDatas('transits');

                $res .= '行运行星落宫：';
                foreach ($astroData[1]['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= '行运' . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= '本命行星落宫：';
                foreach ($astroData[0]['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= '本命' . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '行星相位：';
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $astroData[1]['planets'][$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($phase['id'] < 10)
                            {
                                $phaseNum++;
                                // 输出时去重
                                if ($phase['id'] > $i)
                                {
                                    $res .= '行运' . $this->planet_name[$i] . '和本命' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                                }
                            }
                        }
                    }
                }
                break;
            case 2:
                /**
                 * 某周运势 三限 thirdprogressed
                 * "三限盘": "三限行星落宫：三限太阳落在第2宫 三限月亮落在第7宫 三限水星落在第2宫 三限金星落在第3宫 三限火星落在第1宫 三限木星落在第8宫 三限土星落在第3宫 三限天王星落在第2宫 三限海王星落在第2宫 三限冥王星落在第1宫 宫主星：1宫宫主星冥王 2宫宫主星木星 3宫宫主星土星 4宫宫主星天王 5宫宫主星海王 6宫宫主星火星 7宫宫主星金星 8宫宫主星水星 9宫宫主星月亮 10宫宫主星太阳 11宫宫主星水星 12宫宫主星金星 行星相位：三限月亮和金星三分相 三限水星和木星四分相 三限水星和土星合相 三限水星和天王星合相 三限水星和海王星合相 三限金星和火星六分相 三限木星和土星对分相 三限木星和天王星四分相 三限木星和海王星四分相"
                 */
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting($userSetting)
                    ->setVersion(2)
                    ->setRecode1($record)
                    ->setAdvance($timeinfo)
                    ->setGetDatas(['thirdprogressed'])
                    ->getAstroDatas();
                $astroData = $astro->getDatas('thirdprogressed');

                $res .= $chartNameEasy . '行星落宫：';
                foreach ($astroData['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '宫主星：';
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                $res .= $chartNameEasy . '行星相位：';
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $astroData['planets'][$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($phase['id'] < 10)
                            {
                                $phaseNum++;
                                // 输出时去重
                                if ($phase['id'] > $i)
                                {
                                    $res .= $chartNameEasy . $this->planet_name[$i] . '和' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                                }
                            }
                        }
                    }
                }

                $res .= $chartNameEasy . '宫头星座：';
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= $h . '宫宫头星座' . $this->sign_name[$house['in_sign_id']] . ' ';
                }
                break;
            case 3:
                /**
                 * 某月运势 月返 lunar_return
                 * "月返盘": "月返行星落宫：月返太阳落在第1宫 月返月亮落在第5宫 月返水星落在第2宫 月返金星落在第11宫 月返火星落在第7宫 月返木星落在第4宫 月返土星落在第5宫 月返天王星落在第6宫 月返海王星落在第6宫 月返冥王星落在第3宫  月返宫主落宫：月返1宫宫主星落在第9宫 月返2宫宫主星落在第7宫 月返3宫宫主星落在第9宫 月返4宫宫主星落在第11宫 月返5宫宫主星落在第2宫 月返6宫宫主星落在第11宫 月返7宫宫主星落在第8宫 月返8宫宫主星落在第1宫 月返9宫宫主星落在第11宫 月返10宫宫主星落在第10宫 月返11宫宫主星落在第9宫 月返12宫宫主星落在第12宫 月返宫主行星相位：月返1宫主和木星三分相 月返2宫主和太阳六分相 月返2宫主和冥王星六分相 月返3宫主和太阳四分相 月返3宫主和水星四分相 月返3宫主和火星四分相 月返3宫主和土星四分相 月返3宫主和冥王星六分相 月返4宫主和天王星三分相 月返5宫主和月亮六分相 月返5宫主和金星四分相 月返5宫主和土星三分相 月返6宫主和金星三分相 月返6宫主和木星六分相 月返6宫主和海王星六分相 月返6宫主和冥王星四分相 月返7宫主和月亮三分相 月返7宫主和金星对分相 月返7宫主和土星四分相 月返7宫主和冥王星合相 月返8宫主和太阳对分相 月返8宫主和月亮六分相 月返9宫主和火星六分相 月返9宫主和木星四分相 月返10宫主和月亮合相 月返10宫主和火星合相 月返10宫主和海王星三分相 月返行星相位：月返太阳和太阳六分相 月返太阳和月亮对分相 月返太阳和月亮合相 月返太阳和火星三分相 月返太阳和海王星合相 月返火星和太阳合相 月返土星和水星四分相 月返土星和木星四分相 月返土星和土星三分相 月返天王星和天王星对分相 月返海王星和水星六分相 月返海王星和金星四分相 月返海王星和天王星四分相 月返海王星和冥王星六分相 月返冥王星和月亮四分相 月返冥王星和火星四分相 月返冥王星和天王星合相 月返冥王星和冥王星合相 月返宫主和宫主相位：月返1宫主和5宫主四分相 月返3宫主和1宫主对分相 月返3宫主和4宫主对分相 月返3宫主和6宫主四分相 月返7宫主和2宫主四分相 月返7宫主和9宫主四分相 月返7宫主和10宫主三分相 月返8宫主和4宫主对分相 月返11宫主和9宫主六分相"
                 */
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting($userSetting)
                    ->setVersion(2)
                    ->setRecode1($record)
                    ->setAdvance($timeinfo)
                    ->setGetDatas(['lunar_return'])
                    ->getAstroDatas();
                $astroData = $astro->getDatas('lunar_return');

                $res .= $chartNameEasy . '行星落宫：';
                foreach ($astroData['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '宫主星：';
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= $chartNameEasy . $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                $res .= $chartNameEasy . '行星相位：';
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $astroData['planets'][$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($i < $phase['id'] && $i < 10 && in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                            {
                                $phaseNum++;
                                $res .= $chartNameEasy . $this->planet_name[$i] . '和' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                            }
                        }
                    }
                    if ($phaseNum === 0)
                    {
                        $res .= $chartNameEasy . $this->planet_name[$i] . '空相 ';
                    }
                }
                break;
            case 4:
                /**
                 * 某年运势 日返 solar_return
                 * "日返盘": "日返行星落宫：日返太阳落在第4宫 日返月亮落在第6宫 日返水星落在第7宫 日返金星落在第4宫 日返火星落在第12宫 日返木星落在第3宫 日返土星落在第1宫 日返天王星落在第6宫 日返海王星落在第11宫 日返冥王星落在第3宫  日返宫主落宫：日返1宫宫主星落在第1宫 日返2宫宫主星落在第1宫 日返3宫宫主星落在第11宫 日返4宫宫主星落在第3宫 日返5宫宫主星落在第8宫 日返6宫宫主星落在第1宫 日返7宫宫主星落在第2宫 日返8宫宫主星落在第4宫 日返9宫宫主星落在第3宫 日返10宫宫主星落在第11宫 日返11宫宫主星落在第1宫 日返12宫宫主星落在第4宫 日返宫主行星相位：日返1宫主和火星六分相 日返1宫主和土星六分相 日返1宫主和天王星对分相 日返2宫主和天王星合相 日返3宫主和火星对分相 日返3宫主和土星合相 日返4宫主和水星六分相 日返4宫主和天王星对分相 日返5宫主和天王星对分相 日返5宫主和海王星三分相 日返5宫主和冥王星三分相 日返6宫主和太阳合相 日返6宫主和水星合相 日返6宫主和木星对分相 日返6宫主和土星合相 日返6宫主和冥王星三分相 日返7宫主和金星合相 日返8宫主和太阳六分相 日返8宫主和月亮对分相 日返8宫主和土星三分相 日返9宫主和太阳三分相 日返9宫主和金星三分相 日返9宫主和天王星六分相 日返9宫主和海王星六分相 日返10宫主和木星三分相 日返10宫主和冥王星对分相 日返行星相位：日返水星和太阳对分相 日返水星和月亮三分相 日返水星和海王星六分相 日返水星和冥王星对分相 日返水星和金星四分相 日返水星和海王星六分相 日返金星和月亮对分相 日返金星和水星四分相 日返金星和木星三分相 日返金星和土星三分相 日返金星和冥王星三分相 日返金星和金星六分相 日返金星和土星合相 日返金星和天王星合相 日返火星和土星四分相 日返火星和天王星对分相 日返火星和冥王星四分相 日返火星和水星合相 日返火星和金星三分相 日返火星和火星对分相 日返海王星和月亮六分相 日返海王星和水星对分相 日返海王星和火星六分相 日返冥王星和水星三分相 日返冥王星和金星六分相 日返冥王星和土星对分相 日返冥王星和天王星四分相 日返冥王星和海王星四分相 日返宫主和宫主相位：日返2宫主和7宫主四分相 日返3宫主和8宫主四分相 日返7宫主和12宫主对分相 日返10宫主和4宫主对分相 日返10宫主和7宫主四分相 日返10宫主和8宫主六分相"
                 */
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting($userSetting)
                    ->setVersion(2)
                    ->setRecode1($record)
                    ->setAdvance($timeinfo)
                    ->setGetDatas(['solar_return'])
                    ->getAstroDatas();
                $astroData = $astro->getDatas('solar_return');

                $res .= $chartNameEasy . '行星落宫：';
                foreach ($astroData['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '宫主星：';
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= $chartNameEasy . $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                $res .= $chartNameEasy . '行星相位：';
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $astroData['planets'][$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($i < $phase['id'] && $i < 10 && in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                            {
                                $phaseNum++;
                                $res .= $chartNameEasy . $this->planet_name[$i] . '和' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                            }
                        }
                    }
                }
                break;
            case 5:
                /**
                 * 十年运势 次限 progressions
                 * "三限盘": "次限行星落宫：次限太阳落在第6宫 次限月亮落在第2宫 次限水星落在第8宫 次限金星落在第6宫 次限火星落在第2宫 次限木星落在第5宫 次限土星落在第10宫 次限天王星落在第10宫 次限海王星落在第3宫 次限冥王星落在第10宫  次限宫主落宫：次限1宫宫主星落在第7宫 次限2宫宫主星落在第6宫 次限3宫宫主星落在第9宫 次限4宫宫主星落在第12宫 次限5宫宫主星落在第1宫 次限6宫宫主星落在第9宫 次限7宫宫主星落在第3宫 次限8宫宫主星落在第3宫 次限9宫宫主星落在第10宫 次限10宫宫主星落在第8宫 次限11宫宫主星落在第12宫 次限12宫宫主星落在第8宫 次限宫主行星相位：次限1宫主和太阳三分相 次限1宫主和火星六分相 次限1宫主和天王星对分相 次限1宫主和海王星对分相 满足次限2宫主和木星合相 次限3宫主和天王星六分相 次限4宫主和太阳三分相 次限4宫主和火星六分相 次限4宫主和天王星合相 次限5宫主和太阳四分相 次限5宫主和金星六分相 次限5宫主和土星三分相 次限5宫主和海王星对分相 次限6宫主和火星六分相 次限6宫主和海王星四分相 次限7宫主和水星四分相 次限7宫主和金星合相 次限7宫主和火星三分相 次限7宫主和土星对分相 次限8宫主和月亮四分相 次限8宫主和火星三分相 次限9宫主和火星四分相 次限9宫主和木星六分相 次限10宫主和月亮合相 次限10宫主和水星三分相 次限10宫主和土星三分相 次限10宫主和冥王星对分相"
                 */
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting($userSetting)
                    ->setVersion(2)
                    ->setRecode1($record)
                    ->setAdvance($timeinfo)
                    ->setGetDatas(['progressions'])
                    ->getAstroDatas();
                $astroData = $astro->getDatas('progressions');

                $res .= $chartNameEasy . '行星落宫：';
                foreach ($astroData['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], false))
                    {
                        $res .= $chartNameEasy . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                $res .= $chartNameEasy . '宫主星：';
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= $chartNameEasy . $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                $res .= $chartNameEasy . '行星相位：';
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $astroData['planets'][$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($i < $phase['id'] && $i < 10 && in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                            {
                                $phaseNum++;
                                $res .= $chartNameEasy . $this->planet_name[$i] . '和' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                            }
                        }
                    }
                }
                break;
            case 6:
                // 法达
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(true)
                    ->setUserSetting($userSetting)
                    ->setVersion(2);
                $astroData = $astro
                    ->setAdvance($timeinfo)
                    ->setRecode1($record)
                    ->setGetDatas(['firdaria'])
                    ->getAstroDatas()
                    ->getDatas('firdaria');
                // 水星大运-土星小运：2020/12/20-2022/10/29，
                foreach ($astroData['firdaria']['details'] as $k1 => $v1)
                {
                    foreach ($v1['sub'] as $k2 => $v2)
                    {
                        $startDate = str_replace(['年', '月', '日'], ['-', '-', ''], $v2['start']) . ' 00:00:00';
                        $endDate = str_replace(['年', '月', '日'], ['-', '-', ''], $v2['end']). ' 00:00:00';
                        $startDateTime = strtotime($startDate);
                        $endDateTime = strtotime($endDate);
                        // 只取选定时间的法达信息
                        if (($startDateTime <= $endTime && $startDateTime >= $startTime) || ($startDateTime >= $startTime && $endDateTime <= $endTime)
                            || ($endDateTime >= $startTime && $endDateTime < $endTime))
                        {
                            $res .= $this->planet_name[$v1['main']['id']] . '大运-';
                            $res .= $this->planet_name[$v2['id']] . '小运：';
                            $timestr = $v2['start'] . '-' . $v2['end'];
                            $res .= str_replace(['年', '月', '日'], ['/', '/', ''], $timestr) . ' ';
                        }
                    }
                }
                // 行星落宫
                foreach ($astroData['planets'] as $planet)
                {
                    if (in_array($planet['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 16], false))
                    {
                        $res .= '本命' . $this->planet_name[$planet['id']] . '落在第' . $planet['in_house_id'] . '宫 ';
                    }
                }
                // 宫主星
                foreach ($astroData['houses'] as $h => $house)
                {
                    $res .= '本命' . $h . '宫宫主星' . $this->planet_name[$house['protect_ancient_id']] . ' ';
                }
                // 行星相位
                foreach ($astroData['phase'] as $phase)
                {
                    // 行星与上升/天顶的相位
                    if ($phase['id1'] < $phase['id2'] && $phase['id1'] < 10 && in_array($phase['id2'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                    {
                        $res .= '本命' . $this->planet_name[$phase['id1']] . '和' . $this->planet_name[$phase['id2']] . $this->phase_name[$phase['phase_deg']] . ' ';
                    }
                }
                break;
            case 7:
                $res = $record[0]['name'] . '和' . $record[1]['name'] . $chartName . '\n';
                $sex = $record[1]['type'] === 1 ? '他' : '她';
                // 比较1
                $astro = Astrolog::getInstance()
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(true)
                    ->setUserSetting($userSetting)
                    ->setVersion(2);
                $astroData = $astro
                    ->setRecode1($record[0])
                    ->setRecode2($record[1])
                    ->setGetDatas(['synastry'])
                    ->getAstroDatas()
                    ->getDatas('synastry');
                $planets1 = (array)$astroData[1]['planets'];
                // 行星落宫
                for ($i = 0; $i < 10; $i++)
                {
                    $res .= $sex . '的' . $this->planet_name[$i] . '落在我的' . $planets1[$i]['in_house_id'] . '宫 ';
                }
                for ($i = 0; $i < 10; $i++)
                {
                    $pPhase = $planets1[$i]['phase'];
                    $phaseNum = 0;
                    if (!empty($pPhase))
                    {
                        foreach ($pPhase as $phase)
                        {
                            if ($i < $phase['id'] && $i < 10 && in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 20], false))
                            {
                                $phaseNum++;
                                $res .= $sex . '的' . $this->planet_name[$i] . '与我的' . $this->planet_name[$phase['id']] . $this->phase_name[$phase['phase_e']] . ' ';
                            }
                        }
                    }
                }
                break;
            default:

                break;
        }
        $res = rtrim($res, ' ');

        return ['record_info' => $res, 'chart' => $chart, 'record_time' => $record_time];
    }
}
